package com.project.controller;

import com.framework.core.result.APIObjResponse;
import com.project.base.BaseController;
import com.project.biz.CmsSystemConfBiz;
import com.project.common.model.UserInfo;
import com.project.entity.CmsSystemConf;
import com.project.pojo.model.UpdateCmsSystemConfModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * @Description: 系统配置
 * @Author: zhuchi
 * @CreateDate: 2020/12/17 17:15
 * @Version: 1.0
 */
@Api(value = "CmsSystemConfController", description = "系统配置")
@RestController
@RequestMapping("/systemConf")
@Slf4j
public class CmsSystemConfController extends BaseController {

    /**
     * 系统配置业务层接口类
     */
    @Autowired
    private CmsSystemConfBiz systemConfBiz;

    /**
     * 获取系统配置信息
     * @return
     */
    @ApiOperation(value = "获取系统配置信息")
    @GetMapping(value = "/getSystemConf")
    public APIObjResponse<CmsSystemConf> getSystemConf(){
        CmsSystemConf systemConf = this.systemConfBiz.getSystemConf();
        return APIObjResponse.success("查询成功", systemConf);
    }

    /**
     * 修改系统配置信息
     * @return
     */
    @ApiOperation(value = "修改系统配置信息")
    @PostMapping(value = "/updateCmsSystemConf")
    public APIObjResponse<Integer> updateCmsSystemConf(@RequestBody UpdateCmsSystemConfModel updateCmsSystemConfModel){
        UserInfo userInfo = super.getLoginUser();
        int result = this.systemConfBiz.updateCmsSystemConf(updateCmsSystemConfModel, userInfo.getBaseUserId());
        return APIObjResponse.success("查询成功", result);
    }

}
